package app.musicPlayer.domain;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import app.persistencia.CancionLista;
import app.utils.Utiles;

public class InteractiveArrayAdapterListaReproduccion extends ArrayAdapter<CancionLista> {

	private final List<CancionLista> list;
	private final Activity context;
	

	public InteractiveArrayAdapterListaReproduccion(Activity context, List<CancionLista> list) {
		super(context,R.layout.listsviewallsongs, list);
		this.context = context;
		this.list = list;
	}

	static class ViewHolder {
		protected TextView text;
		protected TextView album;
		protected TextView artist;
		protected ImageView image;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if (convertView == null) {
			LayoutInflater inflator = context.getLayoutInflater();
			view = inflator.inflate(R.layout.listsviewallsongs, null);
			final ViewHolder viewHolder = new ViewHolder();
			viewHolder.text = (TextView) view.findViewById(R.id.label2);
			viewHolder.album = (TextView) view.findViewById(R.id.label3);
			viewHolder.artist = (TextView) view.findViewById(R.id.label4);

			viewHolder.image = (ImageView) view.findViewById(R.id.imageView1);
			view.setTag(viewHolder);
		} else {
			view = convertView;
		}
		ViewHolder holder = (ViewHolder) view.getTag();
		holder.text.setText(Utiles.reduce(list.get(position).getTittle(),30));
		//holder.image.setImageResource(R.drawable.listas);
		holder.album.setText(Utiles.reduce(list.get(position).getAlbum(),15));
		holder.artist.setText(Utiles.reduce(list.get(position).getArtist(),15));
		return view;
	}
}
